/**
 * Copyright (c) 2024,  科泰集团教研团队
 * 版权所有，请勿侵权
 */
package com.ktjiaoyu.entity;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
import java.io.Serializable;
/**
 *
 * @author 科泰集团教研团队
 * @packageName com.ktjiaoyu.entity;
 * @fileName Page.java
 * @createTime 2024/10/01 13:00:57
 * @lastModify 2024/10/01 13:00:57
 * @version 1.0.0
 */
public class SysUser implements Serializable {

    private Long id;  //主键ID
    private String account;  //账号
    private String realName;  //真实姓名
    private String password;  //密码
    private Integer sex;  //性别（1:女、2:男）
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;  //出生日期（年-月-日）
    private String phone;  //手机号码
    private String address;  //用户地址
    private Long roleId;  //用户角色id
    private Long createdUserId;  //创建人
    private Date createdTime;  //创建时间
    private Long updatedUserId;  //修改人
    private Date updatedTime;  //修改时间
    private String idPicPath;  //证件照
    private String workPicPath;  //工作照

    // 当前用户角色，须通过关联查询
    private SysRole role;

    public SysUser() {
    }

    public SysUser(Long id, String account, String realName, String password, Integer sex, Date birthday, String phone, String address, Long roleId, Long createdUserId, Date createdTime, Long updatedUserId, Date updatedTime, String idPicPath, String workPicPath, SysRole role) {
        this.id = id;
        this.account = account;
        this.realName = realName;
        this.password = password;
        this.sex = sex;
        this.birthday = birthday;
        this.phone = phone;
        this.address = address;
        this.roleId = roleId;
        this.createdUserId = createdUserId;
        this.createdTime = createdTime;
        this.updatedUserId = updatedUserId;
        this.updatedTime = updatedTime;
        this.idPicPath = idPicPath;
        this.workPicPath = workPicPath;
        this.role = role;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }


    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }


    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }


    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }


    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }


    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }


    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }


    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }


    public Long getCreatedUserId() {
        return createdUserId;
    }

    public void setCreatedUserId(Long createdUserId) {
        this.createdUserId = createdUserId;
    }


    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }


    public Long getUpdatedUserId() {
        return updatedUserId;
    }

    public void setUpdatedUserId(Long updatedUserId) {
        this.updatedUserId = updatedUserId;
    }


    public Date getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(Date updatedTime) {
        this.updatedTime = updatedTime;
    }

    public SysRole getRole() {
        return role;
    }

    public void setRole(SysRole role) {
        this.role = role;
    }

    public int getAge() {
        if (this.birthday == null) {
            return 0;
        }
        //根据生日计算年龄使用LocalDate和Period实现
        LocalDate birthLocalDate = birthday.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        LocalDate currentDate = LocalDate.now();
        return Period.between(birthLocalDate, currentDate).getYears();
    }

    /**
     * 获取
     * @return idPicPath
     */
    public String getIdPicPath() {
        return idPicPath;
    }

    /**
     * 设置
     * @param idPicPath
     */
    public void setIdPicPath(String idPicPath) {
        this.idPicPath = idPicPath;
    }

    /**
     * 获取
     * @return workPicPath
     */
    public String getWorkPicPath() {
        return workPicPath;
    }

    /**
     * 设置
     * @param workPicPath
     */
    public void setWorkPicPath(String workPicPath) {
        this.workPicPath = workPicPath;
    }

}
